#delimit;
set more off;

set logtype text;
log using /home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/append.txt, replace;

set mem 500m;


/********************************************************************************************************************/
*
* This do file takes the Vital Statistics datasets on the injury-related deaths that occur in each year between
* 1981 and 1998 - injuries being accidents, murders, suicides, and injuries of unknown intent - and appends it 
* together into one dataset.  The years between 1981 and 1998 are all years in which ICD-9 - International 
* Classification of Disease version 9 - coding is used to describe the cause of death.  The Vital Stats Mortality
* Files switched to using ICD-10 codes in 1999, which is why data from the years 1999-2004 are appended together
* into a dataset that's seperate than the Vital Stats data from 1999 through 2004
* 
* Program by Dan Carvell, written between Summer 2007 and Spring 2010.  
*
*********************************************************************************************************************/








** the preceding do files did not destring these datasets, with the exception of the year 1981 - ;
** now I'm destringing all of the rest of the years of data, and saving them again to incorporate the destringing;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1982.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1982.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1983.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1983.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1984.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1984.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1985.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1985.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1986.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1986.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1987.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1987.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1988.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1988.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1989.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1989.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1990.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1990.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1991.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1991.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1992.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1992.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1993.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1993.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1994.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1994.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1995.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1995.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1996.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1996.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1997.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1997.dta", replace;

use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1998.dta", clear;
destring, replace;
save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1998.dta", replace;




use "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1981.dta", clear;

** destring this dataset once more, just in case;
destring, replace;

append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1982.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1983.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1984.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1985.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1986.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1987.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1988.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1989.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1990.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1991.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1992.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1993.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1994.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1995.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1996.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1997.dta";
append using "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/short_mort1998.dta";


sort fipsstr datayear;
order fipsstr datayear;

save "/home/dnc2101/Accidental_Deaths/Vital_Stats/Data_For_Appending/Injury_Deaths_81_98.dta", replace;




log close;

